from cache import RedisTools
from celery import Celery
from function import *

celery = Celery('tasks', broker='redis://localhost:6379/0')
tools = RedisTools()
@celery.task
def getOne(url):
    statusCode, body = httpGet(url)
    if statusCode is not False and body is not '':
        tools.addDomain(url)
        contentUrls = getContentUrl(getBodyUrls(body))
        addNum = tools.checkUrlList(contentUrls)
        print("({}) {}".format(addNum, url))
    else:
        print("访问失败 {}".format(url))